home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet 2002 May / Practical Internet May 2002.iso / pc / Software / SiteBuilding / Cpg27.exe / #setuppath# / Objects / Counter / Cool Page EasyCounter.cpao next >
Encoding:
Text File  |  2002-01-28  |  23.5 KB  |  623 lines

  1. <HTML>
  2. <HEAD>
  3. <SCRIPT language="JavaScript">
  4. <!-- Begin
  5. var subtitle = "EasyCounter";
  6. var title = "Cool Page " + subtitle;
  7. var requires_cool_page = "This file is only useful when used as designed in conjunction with Cool Page.";
  8. var requires_coolpage_update = "To edit this object, please upgrade your copy of Cool Page to the latest version.";
  9. var publisher_url = "http://www.coolpage.com";
  10. var unexpected_error = 'An unexpected error occurred. Please notify publisher of this "' + title + '" plugin at ' + publisher_url;
  11. var objects_folder_name = "Objects";
  12. var objects_subfolder = "Counter"; // Cool Page Objects subfolder which contains any folder(s) which contain this file
  13. var num_digits = 10;
  14. var unsupported_image_type = "Only JPEG (JPG), GIF, and PNG image files are supported.\r\nPlease select a different file.";
  15. var apply_first = "To customize the counter digits images, click Browse then Apply.";
  16. var browse_first = "Click Browse before Apply.\r\nApply the change after browsing for the new file.";
  17. var cgi_file = "EasyCounter.cgi";
  18. var is_http = (window.location.protocol.indexOf( "http" ) == 0);
  19.  
  20. document.write( "<TITLE>" + title + "</TITLE>" );
  21.  
  22. function AlertClose( msg )
  23. {
  24.    alert( msg );
  25.    document.write( "</HEAD><BODY></BODY></HTML>" );
  26.    document.close();
  27. }
  28.  
  29. // Is Cool Page API not available thru the DOM?
  30. var undefined, defined;
  31. if( !window.external || !window.external.Undefined || !window.external.Defined
  32.     || (undefined = window.external.Undefined()) == (defined = window.external.Defined()) )
  33. {
  34.    AlertClose( requires_cool_page );
  35. }
  36.  
  37. // Inputs Cool Page API return value, alerts if unexpected error occurred, and returns 'undefined' value if unsuccessful
  38. function ChkErr( line, return_value )
  39. {
  40.     if( return_value == "" || return_value == undefined )
  41.     {
  42.         alert( line );
  43.         AlertClose( unexpected_error );
  44.         return undefined;
  45.     }
  46.     return return_value;
  47. }
  48.  
  49. // No HTML has been set yet for this object, so we are initializing it for 1st time?
  50. if( window.external.GetObjectHTML( "-1" ) == defined )
  51. {
  52.     // Do any initialization of the Cool Page PageHTML object here
  53.     // To avoid possible errors with zero or negative size objects, initialize
  54.     // at least the width to some positive values here
  55.     ChkErr( 54, window.external.SetObjectSize( "-1", "1", "1" ) ); 
  56. }
  57.  
  58. // Not all APIs used by this file are available?
  59. var w, h;
  60. if( !window.external.GetSelectedObject || window.external.GetSelectedObject( "-1" ) == undefined
  61.    || !window.external.GetObjectClass || window.external.GetObjectClass( "-1" ) != "PageHTML"
  62.    || !window.external.GetObjectEditor || window.external.GetObjectEditor( "-1" ) == undefined
  63.    || !window.external.SetObjectEditorName || window.external.SetObjectEditorName( "-1" , title ) == undefined
  64.    || !window.external.GetObjectWidth || (w = window.external.GetObjectWidth( "-1")) == undefined
  65.    || !window.external.GetObjectHeight || (h = window.external.GetObjectHeight( "-1" )) == undefined
  66.    || !window.external.SetObjectSize || window.external.SetObjectSize( "-1", w, h ) == undefined
  67.    || !window.external.GetObjectHTML || (h = window.external.GetObjectHTML( "-1" )) == undefined
  68.    || !window.external.SetObjectHTML || window.external.SetObjectHTML( "-1", (h == defined ? "" : h) ) == undefined
  69.    || !window.external.GetObjectFiles || window.external.GetObjectFiles( "-1", ";" ) == undefined
  70.    || !window.external.SetObjectFiles // unrealistic to check all argument variants here just assume they are supported || window.external.SetObjectFiles( "-1", file0, file1, ... fileN ) == undefined
  71.    || !window.external.CopyFile || window.external.CopyFile( "", "" ) == undefined
  72.    || !window.external.GetFilesList || window.external.GetFilesList( "", "" ) == undefined
  73. )
  74. {
  75.    AlertClose( requires_coolpage_update );
  76. }
  77.  
  78. // Find the Objects folder by assuming that this file is the Editor and permanently resides in Object folder hierarchy
  79. var editor = ChkErr( 78, window.external.GetObjectEditor( "-1" ) );
  80. var i = editor.lastIndexOf( "\\" + objects_folder_name + "\\" + objects_subfolder );
  81. if( i < 0 )
  82. {
  83.     AlertClose( unexpected_error );
  84. }
  85. var objects_folder = editor.substring( 0, i + objects_folder_name.length + 2 );
  86. var digits_folder = objects_folder + "Text\\EasyCounter Digits\\";
  87.  
  88.  
  89. // Extract temporary folder of this page on hard disk, from the browser encoded url
  90. // Cool Page API copies this file from it's permanent folder to a temporary folder while in use
  91. var prefix = "file:///";
  92. var url = window.location.href;
  93. if( url.indexOf( prefix ) != 0 )
  94. {
  95.     alert( unexpected_error );
  96. }
  97. var temp_folder = url.substring( prefix.length, url.lastIndexOf( "/" ) ).replace( /%20/g, " " ).replace( /\//g, "\\" );
  98.  
  99.  
  100. // Parse list of styles and file types from digit images full (0 - 9) sets
  101. // in the EasyCounter Digits folder of Cool Page Objects window.
  102. // If input 'mode' == "options" then a list of <OPTION value="file type">style</OPTION> is written to output
  103. // Else Array( "style", "ext" ) is returned for the first found, or "" values if none found.
  104. function ParseDigitsFolder( mode )
  105. {
  106.     var first_found = new Array( "style", "ext" );
  107.     var folder = digits_folder.substring( 0, digits_folder.length - 1 );
  108.     var file_array = window.external.GetFilesList( folder, "|", "" ).split( "|" );
  109.     if( file_array[0] != "" && file_array[0] != defined )
  110.     {
  111.         for( var i = file_array.length; --i >= 0; )
  112.         {
  113.             var file = file_array[i];
  114.             if( file )
  115.             {
  116.                 var t = file.lastIndexOf( "." );
  117.                 var ext = file.substring( t + 1 );
  118.                 var style = file.substring( file.lastIndexOf( digits_folder ) + digits_folder.length, t - 1 );
  119.                 var j = 9;
  120.                 for( var k = i + 1; --k >= 0; )
  121.                 {
  122.                     var s = file_array[k];
  123.                     if( s == digits_folder + style + j + "." + ext )
  124.                     {
  125.                         if( --j >= 0 )
  126.                         {
  127.                             file_array[k] = 0; // Mark in list that file is used for a Style
  128.                             k = i + 1;
  129.                         }
  130.                         else if( mode == "options" )
  131.                         {
  132.                             document.writeln( '<OPTION value="' + ext + '">' + style + '</OPTION>' );
  133.                             break;
  134.                         }
  135.                         else
  136.                         {
  137.                             first_found["style"] = style;
  138.                             first_found["ext"] = ext;
  139.                             return first_found;
  140.                         }
  141.                     }
  142.                 }
  143.             }
  144.         }
  145.     }
  146.     return first_found;
  147. }
  148.  
  149.  
  150. // Return the current values of the selected Cool Page PageHTML object,
  151. // or return the default values if the HTML == "" for the object
  152. function ParseHTML()
  153. {
  154.     var current = new Array( "width", "height", "digit_images", "preview_count" );
  155.  
  156.     current["width"] = ChkErr( 155, window.external.GetObjectWidth( "-1" ) );
  157.     current["height"] = ChkErr( 156, window.external.GetObjectHeight( "-1" ) );
  158.  
  159.     // Initialize any files which get uploaded with the web page for the Cool Page PageHTML object
  160.     current["digit_images"] = new Array( num_digits );
  161.  
  162.     // Read (parse) any current files for the Cool Page PageHTML object
  163.     var file_array = ChkErr( 162, window.external.GetObjectFiles( "-1", "|" ) ).split( "|" );
  164.     if( file_array[0] != defined && file_array.length == num_digits )
  165.     {
  166.         for( var i = num_digits; --i >= 0; )
  167.         {
  168.             current["digit_images"][i] = file_array[i];
  169.         }
  170.     }
  171.     else
  172.     {
  173.         if( file_array[0] != defined && file_array.length != num_digits )
  174.         {
  175.             alert( unexpected_error );
  176.         }
  177.  
  178.         // Initialize instead
  179.         var default_digits = ParseDigitsFolder( 0 );
  180.         for( var i = num_digits; --i >= 0; )
  181.         {
  182.             current["digit_images"][i] = digits_folder + default_digits["style"] + i + "." + default_digits["ext"];
  183.         }
  184.     }
  185.  
  186.     // Initialize any variables which are persistant in the HTML for the Cool Page PageHTML object
  187.     current["preview_count"] = '9876543210';
  188.  
  189.     // Read (parse) any variables which are persistant in the HTML for the Cool Page PageHTML object
  190.     var html = ChkErr( 189, window.external.GetObjectHTML("-1") );
  191.     if( html == defined )
  192.         return current;
  193.  
  194.     var s = 'var easy_counter_count = ';
  195.     var i = html.indexOf( s );
  196.     if( i < 0 )
  197.     {
  198.         alert( unexpected_error );
  199.     }
  200.     else
  201.     {
  202.         var s = html.substring( i + s.length );
  203.         i = s.indexOf( ';' );
  204.         if( i < 0 )
  205.         {
  206.             alert( unexpected_error );
  207.         }
  208.         else
  209.         {
  210.             current["preview_count"] = s.substring( 0, i );
  211.         }
  212.     }
  213.  
  214.     return current;
  215. }
  216.  
  217.  
  218. function Max( a, b )
  219. {
  220.     return a > b ? a : b;
  221. }
  222.  
  223.  
  224. // Return index, within <OPTIONS> of input <SELECT>, of counter Style chosen,
  225. // based on the current digit images of the <FORM> that contains the <SELECT>
  226. function ReadStyleIndex( select )
  227. {
  228.     var file = select.form.digit0.value;
  229.     var t = file.lastIndexOf( "." );
  230.     var ext = file.substring( t + 1 );
  231.     var style = file.substring( file.lastIndexOf( digits_folder ) + digits_folder.length, t - 1 );
  232.     for( var i = num_digits; --i >= 0; )
  233.     {
  234.         eval( 'var s = select.form.digit' + i + '.value;' );
  235.         if( s != digits_folder + style + i + "." + ext )
  236.         {
  237.             break;
  238.         }
  239.     }
  240.  
  241.     // Search for index of style (all digit images same style)?
  242.     if( i < 0 )
  243.     {
  244.         for( var i = select.length; --i >= 0; )
  245.         {
  246.             if( select.options[i].text == style && select.options[i].value == ext )
  247.             {
  248.                 return i;
  249.             }
  250.         }
  251.     }
  252.  
  253.     // Return index of "Customize" style
  254.     return select.length - 1;
  255. }
  256.  
  257.  
  258. // Read the values of the currently selected Cool Page PageHTML object,
  259. // and set the values for the GUI <FORM> in this file
  260. function ReadSelectedObject( form )
  261. {
  262.     var current = ParseHTML();
  263.  
  264.     ///////////////////////
  265.     // Write parsed values into the <FORM>
  266.     for( var i = num_digits; --i >= 0; )
  267.     {
  268.         eval( 'form.digit' + i + '.value = current["digit_images"][i];' );
  269.     }
  270.  
  271.     var i = ReadStyleIndex( form.cstyle );
  272.     form.cstyle.selectedIndex = i;
  273.     form.cstyle.options[i].selected = true;
  274.  
  275.     form.count.value = current["preview_count"];
  276.    
  277.     ///////////////////////
  278.     // Copy any images displayed or files used in this file to the current temporary folder
  279.     // The Cool Page API will delete these temporary files when no longer in use
  280.     // Note these are files which MUST be in the same folder as this file,
  281.     // when the embedded browser is displaying this file
  282.  
  283.     // Copy any files from where this page normally resides (this file is the 'editor')
  284.     // to the temporary folder where this file is currently being browsed from
  285. /* This file currently uses no such files but code kept here for example
  286.     var applet = editor.substring( 0, editor.lastIndexOf( "\\" ) + 1 ) + applet_file;
  287.     ChkErr( 285, window.external.CopyFile( applet, temp_folder ) );
  288. */
  289.  
  290.     // Copy any files from where they are to the temporary folder where this file is currently being browsed from
  291.     for( var i = num_digits; --i >= 0; )
  292.     {
  293.         eval( 'window.external.CopyFile( form.digit' + i + '.value, temp_folder );' );
  294.     }
  295. }
  296.  
  297.  
  298. // Return Array( "width", "height", "sizes" ) based on the size of the digit images,
  299. // where sizes is an Array( 'num_digits' ) of Array( "width", "height" ).
  300. function CalcSize( form )
  301. {
  302.     // Copy any files from where they are to the temporary folder where this file is currently being browsed from
  303.     for( var i = num_digits; --i >= 0; )
  304.     {
  305.         eval( 'window.external.CopyFile( form.digit' + i + '.value, temp_folder );' );
  306.     }
  307.  
  308.     var t = new Array( "width", "height", "sizes" );
  309.     t["sizes"] = new Array( num_digits );
  310.     var w = 0, h = 0;
  311.     for( var i = num_digits; --i >= 0; )
  312.     {
  313.         eval( 'var s = form.digit' + i + '.value ;' );
  314.         var img = new Image();
  315.         img.src = s.substring( s.lastIndexOf( "\\" ) + 1 );
  316.         // Width and height of image not loaded yet?
  317.         if( !img.width || !img.height )
  318.         {
  319.             // Use a complex loop not optimized by browser to give time for browser cache to load the image
  320.             i++;
  321.             continue;
  322.         }
  323.         t["sizes"][i] = new Array( "width", "height" );
  324.         t["sizes"][i]["width"] = img.width;
  325.         t["sizes"][i]["height"] = img.height;
  326.         w = Max( img.width, w );
  327.         h = Max( img.height, h );
  328.     }
  329.  
  330.     // Allocate enough width for maximum of 1 billion (10 digits) counter hits, or preview count length, plus a fudge factor of 1 digit
  331.     var cnt = new String( form.count.value );
  332.     t["width"] = w * (Max( 10, cnt.length ) + 1);
  333.     t["height"] = h;
  334.     return t;
  335. }
  336.  
  337.       
  338. // Write the values for the GUI <FORM> in this file, into the values of the currently Cool Page PageHTML object
  339. // Returns true if successful
  340. function WriteSelectedObject( form )
  341. {
  342.     // If any required values are empty, then assume the <FORM> is in a transistional state (this function called
  343.     // from event trigger) and thus return without doing any thing
  344.     for( var i = num_digits; --i >= 0; )
  345.     {
  346.         eval( 'var t = form.digit' + i + '.value;' );
  347.         if( t == "" )
  348.         {
  349.             return false;
  350.         }
  351.     }
  352.  
  353.     // Read the current values of the Cool Page PageHTML object
  354.     var current = ParseHTML();
  355.  
  356.     // Get the width and height from the size of the digit images
  357.     var size = CalcSize( form );
  358.  
  359.     // If not possible to set needed width and height, the assume Cool Page has warned the user
  360.     // and just return without setting the rest of current values
  361.     if(!ChkErr( 359, window.external.SetObjectSize( "-1", size["width"].toString(), size["height"].toString() ) ) )
  362.         return false;
  363.  
  364.     // Derive from the <FORM>, the HTML for the selected Cool Page PageHTML
  365.     var html = DerivedHTML( form );
  366.  
  367.     // Set the list of files to empty before setting HTML, because Cool Page warns user if
  368.     // any files in list are not referenced in the HTML.
  369.     ChkErr( 367, window.external.SetObjectFiles( "-1" ) ); 
  370.     ChkErr( 368, window.external.SetObjectHTML( "-1", html ) );
  371.  
  372.     // Set list of files referenced by the HTML
  373.     var command = 'ChkErr( 371, window.external.SetObjectFiles( "-1"';
  374.     for( var i = 0; i < num_digits; i++ )
  375.     {
  376.         eval( 'var file = form.digit' + i + '.value;' );
  377.         if( file != "" )
  378.             command += ', form.digit' + i + '.value';
  379.     }
  380.     eval( command + ' ) );' );
  381.  
  382.     // If any value has changed, then reload this file (web page) so that any preview of the
  383.     // DerivedHTML() on this web page is updated
  384.     if( form.count.value != current["preview_count"] )
  385.     {  
  386.         window.location.reload( true );
  387.     }
  388.     for( var i = num_digits; --i >= 0; )
  389.     {
  390.         eval( 'if( form.digit' + i + '.value != current["digit_images"][i] ) { window.location.reload( true ); }' );
  391.     }
  392.  
  393.     return true;
  394. }
  395.  
  396.  
  397. // Derive the HTML for the selected Cool Page PageHTML object from the value of the <FORM>
  398. function DerivedHTML( form )
  399. {
  400.     var cr = '\r\n';
  401.     var html = '<' + '!-- Begin Cool Page : EasyCounter(tm) --' + '>' +cr
  402.         // Default counter value
  403.         +    '<' + 'SCRIPT language="JavaScript"' + '>' +cr
  404.         +    '<' + '!--' +cr
  405.         +    'var easy_counter_count = ' + form.count.value + ';' +cr
  406.         +    'var easy_counter_supported = 0;' +cr
  407.         +    '//--' + '>' +cr
  408.         +    '<' + '/SCRIPT' + '>' +cr;
  409.  
  410.         // Call the Host cgi script to return the EasyCounterCount() value
  411.     html +=
  412.             '<' + 'SCRIPT language="php"' + '>' +cr
  413.         +    '//<' + '!--' +cr
  414.         +    'if( !function_exists( "file_exists2" ) )' +cr
  415.         +    '{' +cr
  416.         +    '    function file_exists2( $f, $paths, $delimiter )' +cr
  417.         +    '    {' +cr
  418.         +    '        $d = explode( $delimiter, $paths );' +cr
  419.         +    '        while( (list( $k, $path ) = each( $d )) != 0 )' +cr
  420.         +    '        {' +cr
  421.         +    '            if( file_exists( $path . "/" . $f ) )' +cr
  422.         +    '                return true;' +cr
  423.         +    '        }' +cr
  424.         +    '        return false;' +cr
  425.         +    '    }' +cr
  426.         +    '}' +cr
  427.         +cr
  428.         +    '$file = "EasyCounter.php";' +cr
  429.         +    'if( file_exists( $file ) || file_exists2( $file, ini_get( "include_path" ), ":" ) )' +cr
  430.         +    '{' +cr
  431.         +    '    include $file;' +cr
  432.         +    '    if( function_exists( "EasyCounterCount" ) )' +cr
  433.         +    '    {' +cr
  434.         +    '        echo "<", "SCRIPT language=\\"JavaScript\\">\\n";' +cr
  435.         +    '        echo "<", "!--\\n";' +cr
  436.         +    '        echo "easy_counter_count = ", EasyCounterCount(), ";\\n";' +cr
  437.         +    '        echo "easy_counter_supported = 1;\\n";' +cr
  438.         +    '        echo "//--", ">\\n";' +cr
  439.         +    '        echo "<", "/SCRIPT", ">\\n";' +cr
  440.         +    '    }' +cr
  441.         +    '}' +cr
  442.         +    '//--' + '>' +cr
  443.         +    '<' + '/SCRIPT' + '>' +cr;
  444.  
  445.         // Output the digit images
  446.     html +=
  447.             '<' + 'SCRIPT language="JavaScript"' + '>' +cr
  448.         +    '<!--' +cr
  449.         +    'var digits = new Array( ' + num_digits + ' );' +cr
  450.         +    'for( var i = ' + num_digits + '; --i >= 0; ) { digits[i] = new Array( "file", "width", "height" ); }' +cr;
  451.  
  452.     var sizes = CalcSize( form )["sizes"];
  453.     for( var i = num_digits; --i >= 0; )
  454.     {
  455.         eval( 'var f = form.digit' + i + '.value;' );
  456.         f = f.substring( f.lastIndexOf( '\\' ) + 1 );
  457.         html += 'digits[' + i + ']["file"] = "' + f + '";' +cr;
  458.         html += 'digits[' + i + ']["width"] = ' + sizes[i]["width"] + ';' +cr;
  459.         html += 'digits[' + i + ']["height"] = ' + sizes[i]["height"] + ';' +cr;
  460.     }
  461.  
  462.     html +=
  463.             'var cnt = new String( easy_counter_count );' +cr
  464.         +    'var alt = (easy_counter_supported ? cnt : (is_http ? "EasyCounter not supported on this Host" : "Preview value for EasyCounter"));' +cr
  465.         +    'for( var i = 0; i < cnt.length; i++ )' +cr
  466.         +    '{' +cr
  467.         +    '    var j = cnt.charAt(i);' +cr
  468.         +    "    document.write( '<' + 'IMG SRC=\"' + digits[j]['file'] + '\" ALT=\"' + alt + '\" WIDTH=' + digits[j]['width'] + ' HEIGHT=' + digits[j]['height'] + ' BORDER=0 HSPACE=0 VSPACE=0' + '>' );" +cr
  469.         +    '}' +cr
  470.         +    "document.writeln( '<' + 'BR' + '>' );" +cr // fix last line spacing with small font bug
  471.         +    '//--' + '>' +cr
  472.         +    '<' + '/SCRIPT' + '>' +cr
  473.         // If no JavaScript, then output text preview count
  474.         +    '<' + 'NOSCRIPT' + '>' + form.count.value + '<' + '/NOSCRIPT' + '>' +cr
  475.         +    '<' + '!-- End Cool Page : EasyCounter(tm) --' + '>' +cr;
  476.     return html;
  477. }
  478.  
  479.  
  480. // Process change events on the Style <SELECT> of GUI <FORM>
  481. function OnStyleChange( select )
  482. {
  483.     var style = select.options[select.selectedIndex].text;
  484.     var ext = select.options[select.selectedIndex].value;
  485.     // Style != "Customize" so set the digit images for the selected style?
  486.     if( ext != "" )
  487.     {
  488.         for( var i = num_digits; --i >= 0; )
  489.         {
  490.             eval( 'select.form.digit' + i + '.value = digits_folder + style + i + "." + ext;' );
  491.         }
  492.     }
  493.     else
  494.     {
  495.         alert( apply_first );
  496.     }
  497.     WriteSelectedObject( select.form );
  498. }
  499.  
  500.  
  501. // Process onMouseDown events on the Apply button for Digit Images of GUI <FORM>
  502. function OnApplyNewImage( form, index )
  503. {
  504.     eval( 'var t = form.newdigit' + index + '.value;' );
  505.  
  506.     // Insure user Browses before Apply
  507.     eval( 'form.newdigit' + index + '.value = "";' );
  508.     if( t == "" )
  509.     {
  510.         alert( browse_first );
  511.         return;
  512.     }
  513.  
  514.     var ext = t.substring( t.lastIndexOf( "." ) + 1 ).toLowerCase();
  515.     if( ext == "jpg" || ext == "gif" || ext == "jfi" || ext == "jpeg" || ext == "png" )
  516.     {
  517.         // Before setting new image, insure that Style = "Customize"
  518.         form.cstyle.selectedIndex = form.cstyle.length - 1;
  519.  
  520.         eval( 'form.digit' + index + '.value = t;' );
  521.         WriteSelectedObject( form );
  522.     }
  523.     else
  524.     {
  525.         alert( unsupported_image_type );
  526.     }
  527. }
  528. // End -->
  529. </SCRIPT>
  530.  
  531. <STYLE type="text/css">P, TD {font:normal 10pt Arial, sans-serif; color:#000000}</STYLE>
  532. </HEAD>
  533.  
  534.  
  535. <!-- Begin <BODY> of GUI that will appear embedded in Cool Page for editing the selected PageHTML -->
  536. <BODY SCROLL="auto" BGCOLOR="#d0ccc4">
  537.  
  538. <SCRIPT language="JavaScript">
  539. <!-- Begin
  540. var tm = '<' + 'SUP' + '><' + 'SMALL' + '>TM<' + '/SMALL' + '><' + '/SUP' + '>';
  541. document.writeln( '<' + 'CENTER' + '><' + 'H2' + '>' + title + tm + '<' + '/H2' + '>' );
  542. document.writeln( '<' + 'H3' + '>Easiest, fastest, most customizable counter.<' + '/H3' + '><' + '/CENTER' + '>' );
  543. document.writeln( '<' + 'P' + '>This counter <' + 'B' + '>ONLY<' + '/B' + '> works on ' + subtitle + tm + ' compatible Hosts.<' + 'BR' + '>' );
  544. document.writeln( 'When Publishing, set Host = "Cool Page", Host = "EzHoster", or visit the ' );
  545. document.writeln( '<' + 'A HREF="http://coolpagehelp.com/easycounter.html" TARGET="_new"' + '><' + 'B>Counters<' + '/B' + '><' + '/A> guide at <' + 'A HREF="http://coolpagehelp.com" TARGET="_new"' + '><' + 'B>CoolPageHelp.com<' + '/B' + '><' + '/A' + '> for list of ' + subtitle + tm + ' compatible Hosts.<' + 'BR' + '><' + '/P' + '>' );
  546. // End -->
  547. </SCRIPT>
  548.  
  549. <FORM name="editor" action="">
  550.  
  551. <P align="center">Style: 
  552. <SELECT name="cstyle" onChange="javascript:OnStyleChange( this );">
  553. <SCRIPT language="JavaScript">
  554. <!-- Begin
  555. // Write list of <OPTION> styles from digit images full (0 - 9) sets in the EasyCounter Digits folder
  556. // of Cool Page Objects window
  557. ParseDigitsFolder( "options" );
  558. // End -->
  559. </SCRIPT>
  560. <OPTION value="">Customize</OPTION>
  561. </SELECT>
  562. </P>
  563.  
  564. <P>Choose a Style above, or choose any image you want to use for the counter digits below:</P>
  565. <TABLE align="center">
  566. <SCRIPT language="JavaScript">
  567. <!-- Begin
  568. for( var i = 0; i < num_digits; i++ )
  569. {
  570.     document.writeln( '<' + 'TR' + '>' );
  571.     document.writeln( '    <' + 'TD' + '>Digit ' + i + ' Image:<' + '/TD' + '>' );
  572.     document.writeln( '    <' + 'TD' + '><' + 'INPUT type="text" size="50" name="digit' + i + '" onFocus="javascript:this.blur();"' + 'TITLE="File to use for digit ' + i + ' of counter">' );
  573.     document.writeln( '        <' + 'INPUT type="file" size="1" name="newdigit' + i + '"' + 'TITLE="Browse for a file to use for digit ' + i + ' of counter">' );
  574.     document.writeln( '        <' + 'INPUT type="button" value="Apply" onMouseDown="javascript:OnApplyNewImage( this.form, ' + i + ' );"' + 'TITLE="Apply the file chosen with Browse for digit ' + i + ' of counter">' );
  575.     document.writeln( '    <' + '/TD' + '>' );
  576.     document.writeln( '<' + '/TR' + '>' );
  577. }
  578. // End -->
  579. </SCRIPT>
  580. </TABLE>
  581.  
  582. <P align="center">Preview Count: 
  583. <INPUT type="text" size="10" maxlength="10" name="count" onChange="javascript:this.value=this.value.replace( /[^0-9]/g, '' );WriteSelectedObject( this.form );" TITLE="Count displayed when web page is Previewed">
  584. </P>
  585.  
  586. </FORM>
  587.  
  588. <SCRIPT language="JavaScript">
  589. <!-- Begin
  590. ReadSelectedObject( document.editor );
  591. document.writeln( '<' + 'P align="center"' + '>' + DerivedHTML( document.editor ) + '<' + '/P' + '>' );
  592.  
  593. // Make sure we set the default values in the PageHTML to initialize it when the PageHTML is first created,
  594. // e.g. dropped into the web page.  This is done here instead of at top of this page, because we desire to
  595. // use WriteSelectedObject() which depends on the "document.editor" <FORM>.
  596. if( window.external.GetObjectHTML( "-1" ) == defined )
  597. {
  598.    WriteSelectedObject( document.editor );
  599. }
  600. // End -->
  601. </SCRIPT>
  602.  
  603. <P><B>Add Styles:</B> To add new Styles to this counter, simply add images for all 10 digits (0 - 9) to the
  604. "<I>EasyCounter Digits</I>" folder within the "<I>Text</I>" folder of the Objects window.  Open the "<I>Text</I>"
  605. folder by clicking it's "+" sign in the left pane of the Objects window.  All 10 digits of a Style much have the
  606. same file name, except for the number "0" - "9" appended.  See the existing images in the "<I>EasyCounter Digits</I>"
  607. folder for examples.  Visit the <A HREF="http://coolpagehelp.com/easycounter.html" TARGET="_new"><B>Counters</B></A>
  608. guide at <A HREF="http://coolpagehelp.com" TARGET="_new"><B>CoolPageHelp.com</B></A> for easy instructions for obtaining
  609. and adding more Styles to this counter.</P>
  610.  
  611. <P><B>Technical Note:</B> This counter uses a super-fast innovative technology.  Other counters typically load a
  612. dynamic image from the Host server.  This counter retrieves only the numeric value from the server, then assembles
  613. the digit images on the client (in the browser).  Thus the digit images are cached (by the browser and internet
  614. caches) resulting in faster page load times, and less Host resources used.  Convince your Host to support this
  615. counter.  Tell your Host to read the EasyCounter specification in the Extending Cool Page section of User Manual in
  616. Cool Page Help menu.</P>
  617.  
  618. <P><B>Speed Note:</B> Like all other counters, this counter will be as fast as the speed of the Host script, and at
  619. non-cache times, as fast as the file size of the digit images can be loaded.  The difference is that at cache times
  620. (usually most of the time), this counter will not have to wait to load the digit images.</P>
  621. </BODY>
  622. </HTML>
  623.